typedef struct MinStack
{
    int data;
    struct MinStack *next;
} MinStack;


MinStack* minStackCreate() {
    MinStack *new=(MinStack *)malloc(sizeof(MinStack));
    new->data=0;
    new->next=NULL;
    return new;
}

void minStackPush(MinStack* obj, int val) {
    MinStack *new=(MinStack *)malloc(sizeof(MinStack));
    new->data=val;
    new->next=obj->next;
    obj->next=(struct MinStack*)new;

}

void minStackPop(MinStack* obj) {
    if(obj->next==NULL)//空
    return;
    else if(obj->next!=NULL)
    {
        MinStack* frees=obj->next;
        obj->next=frees->next;
        free(frees);
    }
}

int minStackTop(MinStack* obj) {
    return (obj->next->data);
}

int minStackGetMin(MinStack* obj) {
    MinStack *p=obj->next;
    int min=p->data;
    while(p!=NULL)
    {
        if(p->data<min)
        {
            min=p->data;
        }
        p=p->next;
    }
    return min;
}

void minStackFree(MinStack* obj) {
    MinStack *o=obj->next;
    while(o!=NULL)
    {
        
        MinStack *p=o;
        o=o->next;
        free(p);

    }
}